package com.mindskip.xzs.repository;

import com.mindskip.xzs.domain.Subject;
import com.mindskip.xzs.repository.base.MyMapper;
import com.mindskip.xzs.viewmodel.admin.education.SubjectPageRequestVM;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface SubjectMapper extends MyMapper<Subject> {
    //    int deleteByPrimaryKey(Integer id);
//
//    int insert(Subject record);
//
//    int insertSelective(Subject record);
//
//    Subject selectByPrimaryKey(Integer id);
//
//    int updateByPrimaryKeySelective(Subject record);
//
//    int updateByPrimaryKey(Subject record);
    String queryParams = " id, name, level, level_name levelName, item_order itemOrder, deleted ";

    @Select("select " + queryParams +
            "from t_subject where level= #{level}\n" +
            "order by item_order")
    List<Subject> getSubjectByLevel(Integer level);

//    List<Subject> allSubject();

    @Select("<script>" +
            "select " + queryParams +
            "FROM t_subject where deleted=0 " +
            "<if test=\"id != null \">\n" +
            "and id= #{id}\n" +
            "</if>\n" +
            "<if test=\"level != null \">\n" +
            "and level= #{level}\n" +
            "</if>" +
            "</script>")
    List<Subject> page(SubjectPageRequestVM requestVM);
}
